# 错误代码
#  定义买水的函数，nW 表示新水的数量，nB 表示新瓶的数量，nL 表示新盖的数量
# def f(nW, nB, nL):
#     global Water, bottle, lid
#     bottle = nB + nW
#     lid = nL + nW
#     nW = bottle // 2 + lid
#     Water += nW
#     bottle = bottle %
#     lid = lid % 3
#     if (nB < 2 or nL < 3 or nW < 1):
#         return
#     else:
#         f(nW, nB, nL)
# f(Water, 0, 0)
# print(Water)
# 正确代码
Water = int(input('请输入钱数：'))
# 定义买水的函数，nW 表示新水的数量，nB 表示新瓶的数量，nL 表示新盖的数量
def f(nW, nB, nL):
    global Water, bottle, lid
    bottle = nB + nW
    lid = nL + nW
    nW = bottle // 2 + lid // 3
    Water += nW
    nB = bottle % 2
    nL = lid % 3
    if (nB < 2 and nL < 3 and nW < 1):
        return
    else:
        f(nW, nB, nL)
f(Water, 0, 0)
print(Water)